# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2022/7/21 0021 1:06
# @Author    :jiaxuesong


import requests

#定义一个接口方法调用类
class ConfigHttp(object):
    #定义初始化函数，确定接口传参
    def __init__(self, m, u, v, h):
        self.method = m
        self.url = u
        self.value = v
        self.header = h

    #定义私有方法
    def __get(self):
        re = requests.get(url=self.url, params=self.value, headers=self.header)
        return re

    def __post(self):
        re = requests.post(url=self.url, data=self.value, headers=self.header)
        return re

    #定义一个外部调用方法
    def run(self):
        #判断method
        if self.method == 'get':
            re = self.__get()
            return re
        elif self.method == 'post':
            re = self.__post()
            return re

